package com.apes.fn.scm.retailOrder.service.tc.commission;

/**
 * @Title: TCFormula
 * @Description:计算公式
 * @author: ZhengZeXian
 * @create: 2021/8/24 15:36
 * 计算公式,配合规则引擎使用
 * 有些公式通用只定义一次后期维护主要引用情况
 */
public class TCFormula {

    /** 销售提成正单 考核成本价 计算公式*/
    protected static final String XSTC_KHCBJ = "if (ORDER_TYPE == 'retailReturn') return -1*T201;\n" +
            "                        return T201;";

    /** 销售提成正单 成本金额 计算公式*/
    protected static final String XSTC_CBJE = "if(PROFIT_AMT==null) PROFIT_AMT=0;\n" +
            "                          if (ORDER_TYPE == 'retailReturn') PROFIT_AMT=PROFIT_AMT_RETURN;\n" +
            "                          if (OPERATION!=null && OPERATION=='赋能店'){\n" +
            "                                if (CLASSIFY_ID!=null && CLASSIFY_ID=='M01010102001'){\n" +
            "                                  return PROFIT_AMT * 1.02;\n" +
            "                                } else {\n" +
            "                                  return PROFIT_AMT * 1.05;\n" +
            "                                }\n" +
            "                          }\n" +
            "                          return PROFIT_AMT;";

    /** 销售提成正单 提成比例/固定金额 计算公式*/
    protected static final String XSTC_TCBL_JE = "double dXSJE = SALE_AMT - DISCOUNT_AMOUNT-NKDK_AMT + HBDK_AMT + FXDK_AMT;\n" +
            "                       double dSJJE = LOCK_PRICE*SALE_QTY;\n" +
            "                        if(OUT_SYSTEM_BUSINESS == 1) {return 5;}\n" +   //OUT_SYSTEM_BUSINESS 体系外合作单位提成金额固定为5元
//            "                        if(CLASSIFY_ID=='M01010102001' && SALE_AMT < YYHDJ*SALE_QTY){return 5*SALE_QTY;}\n" +
            "                        if(!(ORDER_TYPE=='LossQuotation' || ORDER_TYPE=='DS0' || ORDER_TYPE =='directPay' || ORDER_TYPE =='noDirectPay'|| ORDER_TYPE =='retailReturn' || ORDER_TYPE =='replacement')){\n" +
            "                              if (T401==1 && SALE_AMT<dSJJE){\n" +
            "                                    return 0;\n" +
            "                              }\n" +
            "                        }\n" +
            "\n" +
            "                        if (T001>0){\n" +
            "                            return T001;\n" +
            "                        }\n" +
            "                        if (T002>0){\n" +
            "                            return T002;\n" +
            "                        }\n" +
            "\n" +
            "                        double dMLJE = SALE_AMT - (REFER_TAX * SALE_QTY) - DISCOUNT_AMOUNT -NKDK_AMT + HBDK_AMT + FXDK_AMT ;\n" +
            "\n" +
            "                        if (SALE_AMT >0) {\n" +
            "                            if (dMLJE <0 ){return 0;}\n" +
            "                        } else {\n" +
            "                            if (dMLJE >0) {return 0;}\n" +
            "                        }\n" +
            "                        double dZKL = 1;\n" +
            "                        if (YYHDJ != 0){\n" +
            "                           dZKL = SALE_AMT/(YYHDJ*SALE_QTY);\n" +
            "                        }\n" +
            "                        if(dZKL >= T021){\n" +
            "                            return  T011;\n" +
            "                        }else if(dZKL >= T022){\n" +
            "                            return T012;\n" +
            "                        }else if(dZKL >= T023){\n" +
            "                            return T013;\n" +
            "                        }else if(dZKL >= T024){\n" +
            "                            return T014;\n" +
            "                        }\n" +
            "                        return 0;";

    /** 销售提成正单 提成金额 计算公式*/
    protected static final String XSTC_TCJE = "double dXSJE = SALE_AMT - DISCOUNT_AMOUNT-NKDK_AMT + HBDK_AMT + FXDK_AMT;\n" +
            "                       double dSJJE = LOCK_PRICE*SALE_QTY;\n" +
            "                        if(OUT_SYSTEM_BUSINESS == 1) {return 5;}\n" +   //OUT_SYSTEM_BUSINESS 体系外合作单位提成金额固定为5元
//            "                        if(CLASSIFY_ID=='M01010102001' && SALE_AMT < YYHDJ*SALE_QTY){return 5*SALE_QTY;}\n" +
            "                        if(!(ORDER_TYPE=='LossQuotation' || ORDER_TYPE=='DS0' || ORDER_TYPE =='directPay' || ORDER_TYPE =='noDirectPay'|| ORDER_TYPE =='retailReturn' || ORDER_TYPE =='replacement')){\n" +
            "                              if (T401==1 && SALE_AMT<dSJJE){\n" +
            "                                    return 0;\n" +
            "                              }\n" +
            "                        }\n" +
            "                        if((SALE_QTY-DK_QTY) == 0){\n" +
            "                            return 0;\n" +
            "                        }\n" +
            "                        if (T001>0){\n" +
            "                            return dXSJE*T001;\n" +
            "                        }\n" +
            "                        if (T002>0){\n" +
            "                            return (SALE_QTY-DK_QTY)*T002;\n" +
            "                        }\n" +
            "\n" +
            "                        double dMLJE = SALE_AMT - (REFER_TAX * (SALE_QTY - DK_QTY)) - DISCOUNT_AMOUNT -NKDK_AMT + HBDK_AMT + FXDK_AMT ;\n" +
            "\n" +
            "                        if (SALE_AMT >0) {\n" +
            "                            if (dMLJE <0 ){return 0;}\n" +
            "                        } else {\n" +
            "                            if (dMLJE >0) {return 0;}\n" +
            "                        }\n" +
            "                        double dZKL = 1;\n" +
            "                        if (YYHDJ != 0){\n" +
            "                           dZKL = SALE_AMT/(YYHDJ*SALE_QTY);\n" +
            "                        }\n" +
            "                        if(dZKL >= T021){\n" +
            "                            return dMLJE * T011;\n" +
            "                        }else if(dZKL >= T022){\n" +
            "                            return dMLJE * T012;\n" +
            "                        }else if(dZKL >= T023){\n" +
            "                            return dMLJE * T013;\n" +
            "                        }else if(dZKL >= T024){\n" +
            "                            return dMLJE * T014;\n" +
            "                        }\n" +
            "                        return 0;";

    /** 销售提成负单 提成金额 计算公式*/
    protected static final String XSTC_FD_TCJE = "if(OLE_TCJE==0)return 0;\n" +
            "                        if(OLE_SALE_AMT==0){\n" +
            "                            return OLE_TCJE*-1;\n" +
            "                        } else {\n" +
            "                            return OLE_TCJE*(SALE_AMT/OLE_SALE_AMT);\n" +
            "                        }\n" +
            "                        if(OLE_TCJE>0)return OLE_TCJE*-1;";

    /** 销售提成 主销提成金额 计算公式*/
    protected static final String XSTC_ZXTCJE = "if (SUB_SALESMAN == null){\n" +
            "                            return TCJE;\n" +
            "                        }else{\n" +
            "                            return TCJE/2;\n" +
            "                        }";

    /** 销售提成 辅销提成金额 计算公式*/
    protected static final String XSTC_FXTCJE = "if (SUB_SALESMAN == null){\n" +
            "                            return 0;\n" +
            "                        }else{\n" +
            "                            return TCJE/2;\n" +
            "                        }";

    /** 分销售提成基地非定损 考核成本价 计算公式*/
    protected static final String FXXSTC_KHCBJ = "return T201;";

    /** 分销售提成基地非定损 成本金额 计算公式*/
    protected static final String FXXSTC_CBJE = "if(PROFIT_AMT==null) PROFIT_AMT=0;\n" +
            "                        if (OPERATION!=null && OPERATION=='赋能店'){\n" +
            "                            if (CLASSIFY_ID!=null && CLASSIFY_ID=='M01010102001'){\n" +
            "                              return PROFIT_AMT * 1.02;\n" +
            "                            } else {\n" +
            "                              return PROFIT_AMT * 1.05;\n" +
            "                            }\n" +
            "                        }\n" +
            "                        return PROFIT_AMT;";

    /** 分销售提成基地非定损 提成金额 计算公式*/
    protected static final String FXXSTCFDS_TCJE = "double dXSJE = SALE_AMT-DISCOUNT_AMOUNT ;\n" +
            "                       double dSJJE = LOCK_PRICE*SALE_QTY;\n" +
//            "                       if(CLASSIFY_ID=='M01010102001' && SALE_AMT < YXSDJ*SALE_QTY){return 5;}\n" +
            "                       if(!(ORDER_TYPE=='LossQuotation' || ORDER_TYPE=='DS0' || ORDER_TYPE =='directPay' || ORDER_TYPE =='noDirectPay')){\n" +
            "                            if (T401==1 && dXSJE<dSJJE){\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        }\n" +
            "                        if (T401==1 && dXSJE<dSJJE){\n" +
            "                            return 0;\n" +
            "                        }\n" +
            "                        if (T001>0){\n" +
            "                            if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                              return dXSJE*T001*0.5;\n" +
            "                            } else {\n" +
            "                                return dXSJE*T001;\n" +
            "                            }\n" +
            "                        }\n" +
            "                        if (T002>0 ){\n" +
            "                            if(SOURCE_BUSINESS_TYPE_NAME == '定损报价单'){\n" +
            "                                return SALE_QTY*T002*0.5;\n" +
            "                            } else {\n" +
            "                                return SALE_QTY*T002;\n" +
            "                            }\n" +
            "                         }\n" +
            "                        double dMLJE = SALE_AMT - REFER_TAX * SALE_QTY - DISCOUNT_AMOUNT ;\n" +
            "                        if (dMLJE <0) return 0;\n" +
            "                        double dZKL = 1;\n" +
            "                        if (YYHDJ != 0){\n" +
            "                          dZKL = SALE_AMT/(YYHDJ*SALE_QTY);\n" +
            "                        }\n" +
            "                        if(dZKL >= T021){\n" +
            "                            if(SOURCE_BUSINESS_TYPE_NAME == '定损报价单' ){\n" +
            "                                  return dMLJE * T011 *0.5;\n" +
            "                            } else {\n" +
            "                                 return dMLJE * T011;\n" +
            "                            }\n" +
            "                        } else if(dZKL >= T022 ){\n" +
            "                          if(SOURCE_BUSINESS_TYPE_NAME == '定损报价单'){\n" +
            "                              return dMLJE * T012 *0.5;\n" +
            "                          } else {\n" +
            "                              return dMLJE * T012 ;\n" +
            "                          }\n" +
            "                        } else if(dZKL >= T023 ){\n" +
            "                            if(SOURCE_BUSINESS_TYPE_NAME == '定损报价单'){\n" +
            "                                return dMLJE * T013 *0.5;\n" +
            "                            } else {\n" +
            "                                return dMLJE * T013 ;\n" +
            "                            }\n" +
            "                        } else if(dZKL >= T024){\n" +
            "                            if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单'){\n" +
            "                                return dMLJE * T014 *0.5;\n" +
            "                            } else {\n" +
            "                                return dMLJE * T014;\n" +
            "                            }\n" +
            "                        }\n" +
            "                        return 0;";

    /** 分销售提成基地定损 提成金额 计算公式*/
    protected static final String FXXSTCDS_TCJE = "double dXSJE = SALE_AMT-DISCOUNT_AMOUNT ;\n" +
            "                       double dSJJE = LOCK_PRICE*SALE_QTY;\n" +
            "                        if(OUT_SYSTEM_BUSINESS == 1) {return 5;}\n" +   //OUT_SYSTEM_BUSINESS 体系外合作单位提成金额固定为5元
//            "                       if(CLASSIFY_ID=='M01010102001' && SALE_AMT < YXSDJ*SALE_QTY){return 5;}\n" +
            "                       if(!(ORDER_TYPE=='LossQuotation' || ORDER_TYPE=='DS0' || ORDER_TYPE =='directPay' || ORDER_TYPE =='noDirectPay')){\n" +
            "                            if (T401==1 && dXSJE<dSJJE){\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        }\n" +
            "                        if (T401==1 && dXSJE<dSJJE){\n" +
            "                            return 0;\n" +
            "                        }\n" +
            "                        if (SALE_DEPT_ID != SERVICE_DEPT_ID) {\n" +
            "                              if (T001>0){\n" +
            "                                return dXSJE*T001*0.5;\n" +
            "                              }\n" +
            "                        } else {\n" +
            "                            if (T001>0){\n" +
            "                                return dXSJE*T001;\n" +
            "                            }\n" +
            "                        }\n" +
            "                        if(SALE_DEPT_ID != SERVICE_DEPT_ID){\n" +
            "                            if(T002>0){\n" +
            "                                return SALE_QTY*T002*0.5;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            if (T002>0 ){\n" +
            "                                return SALE_QTY*T002;\n" +
            "                            }\n" +
            "                        }\n" +
            "                        double dMLJE = SALE_AMT - REFER_TAX *SALE_QTY - DISCOUNT_AMOUNT ;\n" +
            "                        if (dMLJE <0) return 0;\n" +
            "                        double dZKL = 1;\n" +
            "                        if (YXSDJ != 0){\n" +
            "                          dZKL = SALE_AMT/(YXSDJ*SALE_QTY);\n" +
            "                        }\n" +
            "\n" +
            "                       if(SALE_DEPT_ID != SERVICE_DEPT_ID){\n" +
            "                            if(dZKL >= T021){\n" +
            "                                return dMLJE * T011 *0.5;\n" +
            "                            }else if(dZKL >= T022){\n" +
            "                                return dMLJE * T012 *0.5;\n" +
            "                            }else if(dZKL >= T023){\n" +
            "                                return dMLJE * T013 *0.5;\n" +
            "                            }else if(dZKL >= T024){\n" +
            "                                return dMLJE * T014 *0.5;\n" +
            "                            }\n" +
            "                       }else{\n" +
            "                            if(dZKL >= T021){\n" +
            "                                return dMLJE * T011;\n" +
            "                            }else if(dZKL >= T022){\n" +
            "                                return dMLJE * T012 ;\n" +
            "                            }else if(dZKL >= T023){\n" +
            "                                return dMLJE * T013 ;\n" +
            "                            }else if(dZKL >= T024){\n" +
            "                                return dMLJE * T014 ;\n" +
            "                            }\n" +
            "                        }\n" +
            "                        return 0;";

    /** 年卡提成有套包 主销提成金额 计算公式*/
    protected static final String NKTCYTB_ZXTCJE ="if (SALESMAN == null){return 0;}\n" +
            "                        if(SUB_SALESMAN == null){\n" +
            "                            return TC_AMT;\n" +
            "                        }else{" +
            "                            return TC_AMT/2;\n" +
            "                        }";

    /** 年卡提成有套包 辅销提成金额 计算公式*/
    protected static final String NKTCYTB_FXTCJE ="if (SUB_SALESMAN == null){return 0;}\n" +
            "                        if(SALESMAN == null){\n" +
            "                            return TC_AMT;\n" +
            "                        }else{" +
            "                            return TC_AMT/2;\n" +
            "                        }";

    /** 年卡提成无套包 提成金额 计算公式*/
    protected static final String NKTCWTB_TCJE =" if(OLE_TCJE==0)return 0;\n" +
            "                        if(OLE_TCJE>0)return SALE_AMT/OLE_XSJE*OLE_TCJE;";

    /** 异业开单提成零售负单 提成金额 计算公式*/
    protected static final String YYKDTCFD_TCJE ="if(OLE_TCJE == 0) return 0;\n" +
            "                    if(OLE_TCJE>0)return OLE_TCJE*-1;";

    /** 单据施工提成零售正单 工序1提成 计算公式*/
    protected static final String DJSGTCZD_TCJE1 ="if (WORKER1 != null){\n" +
            //"                        if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                        if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return 4;}\n" +
            "                        if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return 4;}\n" +
            "                            if (T111 > 0){\n" +
            "                                return SALE_AMT*T111;\n" +
            "                            } else if (T121 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T121 *SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T121;\n" +
            "                                }\n" +
            "                            } \n" +
            "                            if(T101 > 0){\n" +
            "                                return SALE_AMT*T101;\n" +
            "                            }\n" +
            "                            if (T102 > 0){\n" +
            "                                return SALE_QTY*T102;\n" +
            "                            } else{\n" +
            "                               return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售正单 提成比例/固定金额1 计算公式*/
    protected static final String DJSGTCZD_TCBL_JE1 ="if (WORKER1 != null){\n" +
            //"                        if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                        if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return 4;}\n" +
            "                        if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return 4;}\n" +
            "                            if (T111 > 0){\n" +
            "                                return T111;\n" +
            "                            } else if (T121 > 0){\n" +
            "                                return T121;\n" +
            "                            } \n" +
            "                            if(T101 > 0){\n" +
            "                                return T101;\n" +
            "                            }\n" +
            "                            if (T102 > 0){\n" +
            "                                return T102;\n" +
            "                            }else {\n" +
            "                                return 0 ;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售正单 工序2提成 计算公式*/
    protected static final String DJSGTCZD_TCJE2 ="if (WORKER2 != null){\n" +
            "\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M'){return 0;}\n" +
            "                            if (T112 != null && T112 > 0){\n" +
            "                                return SALE_AMT*T112;\n" +
            "                            } else if (T122 != null && T122 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T122 *SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T122;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售正单 提成比例/固定金额2 计算公式*/
    protected static final String DJSGTCZD_TCBL_JE2 ="if (WORKER2 != null){\n" +
            "\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M'){return 0;}\n" +
            "                            if (T112 != null && T112 > 0){\n" +
            "                                return T112;\n" +
            "                            } else if (T122 != null && T122 > 0){\n" +
            "                                 return T122;\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售正单 工序3提成 计算公式*/
    protected static final String DJSGTCZD_TCJE3 = "if (WORKER3 != null){\n" +
            //"                        if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M'){return 0;}\n" +
            "                        if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return 5;}\n" +
            "                        if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return 5;}\n" +
            "                            if (T113 > 0){\n" +
            "                                return SALE_AMT*T113;\n" +
            "                            } else if (T123 > 0 ){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T123 *SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T123;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售正单 提成比例/固定金额3 计算公式*/
    protected static final String DJSGTCZD_TCBL_JE3 ="if (WORKER3 != null){\n" +
            //"                        if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M'){return 0;}\n" +
            "                        if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return 5;}\n" +
            "                        if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return 5;}\n" +
            "                            if (T113 > 0){\n" +
            "                                return T113;\n" +
            "                            } else if (T123 > 0 ){\n" +
            "                                return T123;\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售正单 工序4提成 计算公式*/
    protected static final String DJSGTCZD_TCJE4 = "if (WORKER4 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if (T114 > 0){\n" +
            "                                return SALE_AMT*T114;\n" +
            "                            } else if (T124 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null ) {\n" +
            "                                    return SALE_QTY*T124 *SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T124;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售正单 提成比例/固定金额4 计算公式*/
    protected static final String DJSGTCZD_TCBL_JE4 ="if (WORKER4 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if (T114 > 0){\n" +
            "                                return T114;\n" +
            "                            } else if (T124 > 0){\n" +
            "                                return T124;\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售负单 工序1提成 计算公式*/
    protected static final String DJSGTCFD_TCJE1 ="if (WORKER1 != null){\n" +
            //"                        if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                        if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return -4;}\n" +
            "                        if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return -4;}\n" +
            "                            if(T101 > 0){\n" +
            "                                return SALE_AMT*T101;\n" +
            "                            }\n" +
            "                            if (T102 > 0){\n" +
            "                                return SALE_QTY*T102;\n" +
            "                            }\n" +
            "                            if (T111 > 0){\n" +
            "                                return SALE_AMT*T111;\n" +
            "                            } else if (T121 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY * T121 * SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T121;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0 ;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售负单 工序2提成 计算公式*/
    protected static final String DJSGTCFD_TCJE2 ="if (WORKER2 != null){\n" +
            "\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M'){return 0;}\n" +
            "                            if (T112 != null && T112 > 0){\n" +
            "                                return SALE_AMT*T112;\n" +
            "                            } else if (T122 != null && T122 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T122 *SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T122;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售负单 工序3提成 计算公式*/
    protected static final String DJSGTCFD_TCJE3 ="if (WORKER3 != null){\n" +
            //"                        if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M'){return 0;}\n" +
            "                        if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return -5;}\n" +
            "                        if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return -5;}\n" +
            "                            if (T113 > 0){\n" +
            "                                return SALE_AMT*T113;\n" +
            "                            } else if (T123 > 0 ){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T123 *SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T123;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 单据施工提成零售负单 工序4提成 计算公式*/
    protected static final String DJSGTCFD_TCJE4 ="if (WORKER4 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if (T114 > 0){\n" +
            "                                return SALE_AMT*T114;\n" +
            "                            } else if (T124 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null ) {\n" +
            "                                    return SALE_QTY*T124 *SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T124;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";



    /** 分销单据施工提成零售正单 提成比例/固定金额1 计算公式*/
    protected static final String FXDJSGTCZD_TCBL_JE1 ="if (WORKER1 != null){\n" +
            //"                        if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                        if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return 4;}\n" +
            "                        if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return 4;}\n" +
            "                        if (SUBSTR_CLASSIFY == 'S0105' && STORE_TYPE_NAME == '001171' && OPERATION =='001073' && BUSINESS_TYPE == 'inner'){\n" +
            "                                if(T111 > 0){\n" +
            "                                    return T111*2;\n" +
            "                                }\n" +
            "                                if (T121 > 0){\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                                if (T101 > 0){\n" +
            "                                    return T101*2;\n" +
            "                                } else if (T102 > 0){\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T111 > 0 ){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return T111;\n" +
            "                                } else {\n" +
            "                                    return T111 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            }\n" +
            "                            if (T121 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T101 > 0){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return T101;\n" +
            "                                } else {\n" +
            "                                    return T101 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            } else if (T102 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 分销单单据施工提成 定损和非定损的工序提成计算公式目前是一致的*/
    /** 分销单据施工提成 非定损 工序1提成 计算公式*/
    protected static final String FXDJSGTC_TCJE1 ="if (WORKER1 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return 4;}\n" +
            "                            if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return 4;}\n" +
            "                            if (SUBSTR_CLASSIFY == 'S0105' && STORE_TYPE_NAME == '001171' && OPERATION =='001073' && BUSINESS_TYPE == 'inner'){\n" +
            "                                if (T111 > 0){\n" +
            "                                    return SALE_AMT*(T111*2);\n" +
            "                                } else if (T121 > 0){\n" +
            "                                    return SALE_QTY*T121;\n" +
            "                                } \n" +
            "                                if(T101 > 0){\n" +
            "                                    return SALE_AMT*(T101*2);\n" +
            "                                }\n" +
            "                                if (T102 > 0){\n" +
            "                                    return SALE_QTY*T102;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T111 > 0 ){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return SALE_AMT*T111;\n" +
            "                                } else {\n" +
            "                                    return SALE_AMT*T111 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            }\n" +
            "                            if (T121 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T121 *SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T121;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T101 > 0){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return SALE_AMT*T101;\n" +
            "                                } else {\n" +
            "                                    return SALE_AMT*T101 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            } else if (T102 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T102*SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T102;\n" +
            "                                }\n" +
            "\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";


    /** 分销单据施工提成零售正单 提成比例/固定金额2 计算公式*/
    protected static final String FXDJSGTCZD_TCBL_JE2 ="if (WORKER2 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if ((SUBSTR_CLASSIFY == 'S0105') && (STORE_TYPE_NAME == '001171') && (OPERATION == '001073') && (BUSINESS_TYPE == 'inner')){\n" +
            "                                if ( T112 > 0){\n" +
            "                                    return T112*2;\n" +
            "                                } else if (T122 > 0){\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T112 > 0){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return T112;\n" +
            "                                } else {\n" +
            "                                    return T112 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            } else if (T122 != null && T122 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 分销单据施工提成 非定损 工序2提成 计算公式*/
    protected static final String FXDJSGTC_TCJE2 ="if (WORKER2 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if ((SUBSTR_CLASSIFY == 'S0105') && (STORE_TYPE_NAME == '001171') && (OPERATION == '001073') && (BUSINESS_TYPE == 'inner')){\n" +
            "                                if ( T112 > 0){\n" +
            "                                    return SALE_AMT*(T112*2);\n" +
            "                                } else if (T122 > 0){\n" +
            "                                    return SALE_QTY*T122;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T112 > 0){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return SALE_AMT*T112;\n" +
            "                                } else {\n" +
            "                                    return SALE_AMT*T112 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            } else if (T122 != null && T122 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T122*SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T122;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 分销单据施工提成零售正单 提成比例/固定金额3 计算公式*/
    protected static final String FXDJSGTCZD_TCBL_JE3 ="if (WORKER3 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return 5;}\n" +
            "                            if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return 5;}\n" +
            "                            if (SUBSTR_CLASSIFY == 'S0105' && STORE_TYPE_NAME == '001171'  && OPERATION == '001073' && BUSINESS_TYPE == 'inner'){\n" +
            "                                if (T113 > 0){\n" +
            "                                    return T113*2;\n" +
            "                                } else if (T123 > 0){\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T113 > 0){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return T113;\n" +
            "                                } else {\n" +
            "                                    return T113 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            } else if (T123 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";


    /** 分销单据施工提成 非定损 工序3提成 计算公式*/
    protected static final String FXDJSGTC_TCJE3 ="if (WORKER3 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if (PRODUCT_ID == '0000000148' && SALE_AMT == 0.01){return 5;}\n" +
            "                            if (PRODUCT_ID == '0000000418' && SALE_AMT == 0.01){return 5;}\n" +
            "                            if (SUBSTR_CLASSIFY == 'S0105' && STORE_TYPE_NAME == '001171'  && OPERATION == '001073' && BUSINESS_TYPE == 'inner'){\n" +
            "                                if (T113 > 0){\n" +
            "                                    return SALE_AMT*(T113*2);\n" +
            "                                } else if (T123 > 0){\n" +
            "                                    return SALE_QTY*T123;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T113 > 0){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return SALE_AMT*T113;\n" +
            "                                } else {\n" +
            "                                    return SALE_AMT*T113 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            } else if (T123 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T123*SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T123;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";


    /** 分销单据施工提成零售正单 提成比例/固定金额4 计算公式*/
    protected static final String FXDJSGTCZD_TCBL_JE4 ="if (WORKER4 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if (SUBSTR_CLASSIFY == 'S0105' && STORE_TYPE_NAME == '001171' && OPERATION == '001073' && BUSINESS_TYPE == 'inner'){\n" +
            "                                if (T114 > 0){\n" +
            "                                    return T114*2;\n" +
            "                                } else if (T124 > 0){\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T114 > 0){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return T114;\n" +
            "                                } else {\n" +
            "                                    return T114 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            } else if (T124 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return 0;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 分销单据施工提成 非定损 工序4提成 计算公式*/
    protected static final String FXDJSGTC_TCJE4 ="if (WORKER4 != null){\n" +
            //"                            if (STORE_TYPE_NAME == '001171' && SERVE_TYPE_ID== '007' && SUB_CLASSIFY=='M' ){return 0;}\n" +
            "                            if (SUBSTR_CLASSIFY == 'S0105' && STORE_TYPE_NAME == '001171' && OPERATION == '001073' && BUSINESS_TYPE == 'inner'){\n" +
            "                                if (T114 > 0){\n" +
            "                                    return SALE_AMT*(T114*2);\n" +
            "                                } else if (T124 > 0){\n" +
            "                                    return SALE_QTY*T124;\n" +
            "                                } else {\n" +
            "                                    return 0;\n" +
            "                                }\n" +
            "                            }\n" +
            "                            if (T114 > 0){\n" +
            "                                if (SOURCE_BUSINESS_TYPE_NAME == '定损报价单') {\n" +
            "                                  return SALE_AMT*T114;\n" +
            "                                } else {\n" +
            "                                    return SALE_AMT*T114 *2;\n" +
            "                                }\n" +
            "\n" +
            "                            } else if (T124 > 0){\n" +
            "                                if (SUBSTR_CLASSIFY == 'S0106' && SPECIFICATIONS !=null) {\n" +
            "                                    return SALE_QTY*T124*SPECIFICATIONS;\n" +
            "                                } else {\n" +
            "                                    return SALE_QTY*T124;\n" +
            "                                }\n" +
            "                            } else {\n" +
            "                                return 0;\n" +
            "                            }\n" +
            "                        } else {\n" +
            "                            return 0;\n" +
            "                        }";

    /** 人员施工提成 提成金额 计算公式*/
    protected static final String RYSGTC_TCJE = "if(CLASSIFY_ID == 'S01010101001' || CLASSIFY_ID == 'S01010201001' ) {\n" +
            "                                   return PJTC;\n" +
            "                                }\n" +
            "                               return TCJE * (PORTION/SUM_FS);";
}
